const CracoLessPlugin = require('craco-less');
const path = require('path');
const pathResolve = (pathUrl) => path.join(__dirname, pathUrl);

module.exports = {
	webpack: {
		alias: {
			'@@': pathResolve('.'),
			'@': pathResolve('src'),
			'@assets': pathResolve('src/assets'),
			'@common': pathResolve('src/common'),
			'@components': pathResolve('src/components'),
			'@hooks': pathResolve('src/hooks'),
			'@pages': pathResolve('src/pages'),
			'@store': pathResolve('src/store'),
			'@utils': pathResolve('src/utils')
		}
	},
	eslint: {
		enable: true /* (default value) */,
		mode: 'extends' /* (default value) */ || 'file',
		configure: {
			/* Any eslint configuration options: https://eslint.org/docs/user-guide/configuring */
			rules: {
				"jsx-a11y/anchor-is-valid": 0
			},
			globals: {
				TCPlayer: 'readonly'
			},
			// "plugins": [
			// 	"jsx-a11y"
			// ]
		}

		// configure: (eslintConfig, { env, paths }) => { return eslintConfig; },
		// pluginOptions: { /* Any eslint plugin configuration options: https://github.com/webpack-contrib/eslint-webpack-plugin#options. */ },
		// pluginOptions: (eslintOptions, { env, paths }) => { return eslintOptions; }
	},
	plugins: [
		{
			plugin: CracoLessPlugin,
			options: {
				lessLoaderOptions: {
					lessOptions: {
						// modifyVars: { '@primary-color': '#1DA57A' },
						javascriptEnabled: true
					}
				}
			}
		}
	],
	babel: {
		// 支持装饰器模式语法
		plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]]
	},
	//  开发服务
	devServer: {
		proxy: {
			// 代理地址
			'/api': {
				target: 'http://localhost:9001',
				changeOrigin: true,
				pathRewrite: {
					'^/api': ''
				}
			}
		}
	}
};
